package com.weidey.web.controller.tool;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


@Component
public class TestJasyptEncryption  implements CommandLineRunner {

    @Value("${jasypt.encryptor.password}")
    private String password;

    @Override
    public void run(String... args) throws Exception {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setPassword(password); // 设置加密密钥
        String encryptedText = encryptor.encrypt("root");
        String Original = encryptor.decrypt(encryptedText);
        System.out.println("Original Text: "+Original);
        System.out.println("Encrypted Text: " + encryptedText);
    }
}


